FROM harbor.ydwywx.cn/library/python:3.12-slim-bookworm
RUN sed -i s@http://deb.debian.org@https://mirrors.tuna.tsinghua.edu.cn@g /etc/apt/sources.list.d/debian.sources && \
    apt-get clean && apt-get update --fix-missing && apt-get install -y --fix-missing \
    unzip \
    curl \
    wget \
    telnet \
    busybox

RUN rm -rf /var/lib/apt/lists/* && \
    mkdir /app

COPY ./requirements.txt requirements.txt

RUN pip install --root-user-action=ignore -r requirements.txt  -i https://pypi.mirrors.ustc.edu.cn/simple/ && \
    pip cache purge

# Copy source files to build Protobufs
COPY ./ /app

# Generate Protobufs
WORKDIR /app

# Copy entrypoint
COPY ./bin/docker_entrypoint.sh /app/docker_entrypoint.sh

RUN chmod +x /app/docker_entrypoint.sh

# 解决时区问题
ENV TZ=Asia/Shanghai

ENV ENVIRONMENT="prod"
ENV SERVER_HOST="0.0.0.0"
ENV SERVER_PORT=80
ENV SERVER_RELOAD=False
ENV SERVER_WORKERS=1
ENV SERVER_TIMEOUT_KEEP_ALIVE=30

EXPOSE 80

ENTRYPOINT ["/app/docker_entrypoint.sh"]
